**Project: Strategic Discrimination**
**by Regina Bateson**
**Last modified: 21 June 2020**

//This do-file provides the output for the General Social Survey portion of Figure 1.1//

//First, download and save the GSS 1972-2016 cumulative file.//
//It can be obtained here: https://doi.org/10.3886/ICPSR36797.v1 // 

**BASIC SETUP**

//Start by loading your saved copy of the GSS dataset.//

set maxvar 10000
use "/Users/gina/Dropbox (Personal)/Strategic Discrimination resubmit/Perspectives Final Submission/Data and Replication Files/GSS19722016.dta"

//Obviously you'll need to point STATA to your saved copy of the dataset.//

//Now, establish the proper settings for weighting and design-corrected standard errors.//

svyset [weight=WTSSALL], strat(VSTRAT) psu(VPSU) singleunit(scaled)

**CLEAN THE KEY VARIABLES**

//The "not vote for a woman president" variable is called FEPRES//
//Let's start by cleaning the FEPRES variable//
//We'll create a new dummy variable called notvotewoman//

gen notvotewoman=.
replace notvotewoman=0 if FEPRES==1
//These are the folks who said they WOULD vote for a woman pres.//
replace notvotewoman=1 if FEPRES==2
//These are the folks who said they WOULD NOT vote for a woman pres.//
replace notvotewoman=1 if FEPRES==5
//These are the folks who said they WOULD NOT vote period.//
replace notvotewoman=1 if FEPRES==8
//These are the folks who said they "don't know" if they would vote for a woman pres.//
replace notvotewoman=1 if FEPRES==9
//These are the folks who did not answer the question about a woman pres.//

//As explained in the manuscript, I am coding 0 for everyone who did not explicitly//
//say they WOULD vote for a woman for president.//

//Now, let's turn to race.//
//The "not vote for a black president" variable is called RACPRES//

//For this project, we should use data from 1974 and 1978 and later ONLY.//
//In other years, this question was asked of nonblack respondents only, not//
//all respondents.//

//We're going to create a new dummy variable called notvoteblack//

gen notvoteblack=.
replace notvoteblack=0 if RACPRES==1
//These are the folks who said they WOULD vote for a black pres.//
replace notvoteblack=1 if RACPRES==2
//These are the folks who said they WOULD NOT vote for a black pres.//
replace notvoteblack=1 if RACPRES==5
//These are the folks who said they WOULD NOT vote period.//
replace notvoteblack=1 if RACPRES==8
//These are the folks who said they "don't know" if they would vote for a black pres.//
replace notvoteblack=1 if RACPRES==9
//These are the folks who did not answer the question about a black pres.//

//As explained in the manuscript, I am coding 0 for everyone who did not explicitly//
//say they WOULD vote for a black person for president.//

**ANALYSIS FOR FIGURE 1**

//The code below produces the estimated population proportions and confidence intervals//
//shown in Figure 1.1 in the manuscript.//

//First, we'll look at willingess to vote for a WOMAN president//

mean notvotewoman[aweight=WTSSALL] if YEAR==1972
mean notvotewoman[aweight=WTSSALL] if YEAR==1974
//Survey design was recorded differently in 1972 and 74, so you need to use this//
//slightly different code above.//
svy,subpop(if YEAR==1975): mean notvotewoman
svy,subpop(if YEAR==1977): mean notvotewoman
svy,subpop(if YEAR==1978): mean notvotewoman
mean notvotewoman[aweight=OVERSAMP] if YEAR==1982
//The sample was drawn differently in 1982, so that year uses a different weight.//
svy,subpop(if YEAR==1983): mean notvotewoman
svy,subpop(if YEAR==1985): mean notvotewoman
svy,subpop(if YEAR==1986): mean notvotewoman
svy,subpop(if YEAR==1988): mean notvotewoman
svy,subpop(if YEAR==1989): mean notvotewoman
svy,subpop(if YEAR==1990): mean notvotewoman
svy,subpop(if YEAR==1991): mean notvotewoman
svy,subpop(if YEAR==1993): mean notvotewoman
svy,subpop(if YEAR==1994): mean notvotewoman
svy,subpop(if YEAR==1996): mean notvotewoman
svy,subpop(if YEAR==1998): mean notvotewoman
//Sampling was done differently after 2004, so thes years below have different weights//
mean notvotewoman[aweight=WTSSNR] if YEAR==2008
mean notvotewoman[aweight=WTSSNR] if YEAR==2010

//Now, we'll look at willingness to vote for a BLACK president//

mean notvoteblack[aweight=WTSSALL] if YEAR==1974
//The structure of the 1974 data requires the code above.//
svy,subpop(if YEAR==1978): mean notvoteblack
mean notvoteblack[aweight=OVERSAMP] if YEAR==1982
//We need to use a different weight for 1982, because that year included an oversample of Black Americans//
svy,subpop(if YEAR==1983): mean notvoteblack
svy,subpop(if YEAR==1985): mean notvoteblack
svy,subpop(if YEAR==1986): mean notvoteblack
svy,subpop(if YEAR==1988): mean notvoteblack
svy,subpop(if YEAR==1989): mean notvoteblack
svy,subpop(if YEAR==1990): mean notvoteblack
svy,subpop(if YEAR==1991): mean notvoteblack
svy,subpop(if YEAR==1993): mean notvoteblack
svy,subpop(if YEAR==1994): mean notvoteblack
svy,subpop(if YEAR==1996): mean notvoteblack
//Sampling was done differently after 2004, so these years have different weights//
mean notvoteblack[aweight=WTSSNR] if YEAR==2008
mean notvoteblack[aweight=WTSSNR] if YEAR==2010

clear

**That's the end of the GSS data analysis for Figure 1.1.**
**Next, please proceed to Study1_Figure1.do**
